<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>互动管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/web/res/css/xadmin.css">
    <script src="/web/res/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/web/res/js/xadmin.js"></script>
</head>

<body>
    <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">互动管理</a>
                <a><cite>个人动态</cite></a>
            </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
        onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">

                    <div class="layui-card-body">
                        <form class="layui-form layui-col-space5" type="post"  action="/after/dynamic/list">
                            <div class="layui-input-inline layui-show-xs-block">
                                <input type="text" name="nick"  value="${nick!''}"  placeholder="请输入用户名称" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <input type="text" name="phone"  value="${phone!''}"  placeholder="请输入用户手机号" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <input class="layui-input" placeholder="开始时间" autocomplete="off" value="${startDate!''}" name="startDate" id="startdate">
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <input class="layui-input" placeholder="结束时间" autocomplete="off" value="${endDate!''}" name="endDate" id="enddate">
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <button  class="layui-btn" lay-submit lay-filter="search">
                                    <i class="layui-icon">&#xe615;</i>搜索
                                </button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body" style="overflow:auto">
                        <table class="layui-table layui-form tableH"   lay-size="sm"  id="tab">
                            <thead>
                                <tr>
                                    <th>发布人名称</th>
                                    <th>发布人头像</th>
                                    <th>发布人电话</th>
                                    <th>发布内容</th>
                                    <th>发布图片</th>
                                    <th>点赞数量</th>
                                    <th>评论数量</th>
                                    <th>发布时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <#if list?? && (list?size > 0) >
                                <#list list as user>
                                <tr>
                                    <td>${(user.nick)!''}</td>
                                    <td>
                                        <a href="javascript:void(0);" class="img_biges" title="${(user.pic)!''}">
                                        <img src="${(user.pic)!''}" style=" width:35px;height:35px;"/>
                                    </td>
                                    <td>${(user.phone)!''}</td>
                                    <td>${(user.message)!''}</td>
                                    <td>
                                        <#if user.image?? && user.image !=''>
                                                <#if user.image?contains(",")>
                                                    <a href="javascript:void(0);" class="img_biges" title="${(user.image)!''}">
                                                    <img src="${(user.image?split(','))[0]} " style=" width:35px;height:35px;border-radius: 5px;"/>
                                                <#else>
                                                    <a href="javascript:void(0);" class="img_biges" title="${(user.image)!''}">
                                                    <img src="${(user.image)!''}" style=" width:35px;height:35px;border-radius: 5px;"/>
                                                </#if>
                                        <#else>
                                            <div class="divimg"><i class="layui-icon layui-icon-picture-fine"></i></div>
                                        </#if>
                                    </td>
                                    <td>${(user.givenum)!''}</td>
                                    <td>${(user.commentnum)!''}</td>
                                    <td>${user.createtime?string("yyyy-MM-dd HH:mm:ss")!}</td>
                                    <td class="td-manage btn-center">
                                        <button class="layui-btn layui-btn-xs layui-btn-warm" onclick="xadmin.open('查看评论','/after/dynamic/pinglunlist?id=${(user.id)!''}',800,600)" >
                                            <i class="layui-icon layui-icon-edit"></i>查看评论
                                        </button>
                                        <button class="layui-btn layui-btn-xs layui-btn-danger" onclick="del(this,'${user.id}')">
                                            <i class="layui-icon layui-icon-delete"></i>删除
                                        </button>
                                    </td>
                                </tr>
                                </#list>
                                <#else>
                                <tr>
                                    <td colspan="8" style="text-align: center;">暂无记录</td>
                                </tr>
                                </#if>
                            </tbody>
                        </table>
                    </div>
                    <!-- 分页条 -->
                    <div id="pager" style="text-align: center;"></div>
                </div>
            </div>
        </div>
    </div>
</body>

<script>
    layui.use(['laydate', 'form', 'table','carousel'], function () {
        let $ = layui.$;
        var laydate = layui.laydate;
        var form = layui.form;
        var table = layui.table;
        var carousel = layui.carousel;
        //执行一个laydate实例
        laydate.render({
            elem: '#startdate' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#enddate' //指定元素
        });

        //显示图片
        $('.img_biges').on('click', function () {
            const str = $(this).attr('title');
            swiperim(str);
        });


        // 逗号隔开的多图地址预览
      function swiperim(url) {
        var str = url.split(',')
        var htmlstr = '<div class="layui-carousel" id="test10" style="overflow:hidden"><div carousel-item>'
        str.forEach(e => {
          htmlstr += '<div style="line-height:377px;text-align:center;"><img src="' + e + '" style="max-width:100%;max-height:100%;background-size:contain;"></div>'
        })
        htmlstr += '</div></div>'
        layer.open({
          type: 1,
          title: false,
          closeBtn: 0,
          area: ['600px', '377px'],
          skin: 'layui-layer-nobg',
          shadeClose: true,
          content: htmlstr
        });
        //图片轮播
        carousel.render({
          elem: '#test10'
          , width: '600px'
          , height: '377px'
          , interval: 5000
        });
      }

    });
    // 删除
    function del(obj, id) {
        layui.use('layer',function () {
            let $ = layui.$;
            layer.confirm('确认要删除吗？(删除之后数据不可恢复)', function (index) {
                ajaxPost($,"/after/dynamic/deldongtai",{"id":id},function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                        });
                    }
                });
            });
        });
    }

</script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
    <script>
    layui.use(['laypage', 'layer', 'form'], function(){
        let $ = layui.$;
        var laypage = layui.laypage
            ,form = layui.form
            ,layer = layui.layer;

        laypage.render({
            elem: 'pager'
            ,count: ${(splitPage.totalCount?c)!''}
            ,limit: ${(splitPage.pageSize?c)!''}
            ,curr: ${(splitPage.pageIndex?c)!''}
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            ,jump: function(obj, first){
                //首次不执行
                if(!first){
                    var myform = document.forms[0];
                    // alert("formName:"+myform.id);
                    var pageIndex = document.createElement("input");
                    pageIndex.name="pageIndex";
                    pageIndex.type="hidden";
                    pageIndex.value=obj.curr;
                    myform.appendChild(pageIndex);

                    var pageSize = document.createElement("input");
                    pageSize.name="pageSize";
                    pageSize.type="hidden";
                    pageSize.value=obj.limit;
                    myform.appendChild(pageSize);
                    $("button[lay-submit]:eq(0)").click();
                }
            }
        });
    });
</script>


</html>